package com.mobartisan.workinglunch.getui_push;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;


import com.mobartisan.workinglunch.ui.activity.LoginActivity;
import com.mobartisan.workinglunch.ui.activity.MainActivity;
import com.mobartisan.workinglunch.util.ObjectUtils;
import com.mobartisan.workinglunch.util.SharedPreferencesUtil;
import com.mobartisan.workinglunch.util.ToastUtils;

/**
 * Created by liangzili on 15/8/3.
 */
public class NotificationReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String username = SharedPreferencesUtil.getInstance().getStringValue("username");
        String password = SharedPreferencesUtil.getInstance().getStringValue("password");
        if (ObjectUtils.isStringNotEmpty(username)&&ObjectUtils.isStringNotEmpty(password)) {
            Intent mainIntent = new Intent(context, MainActivity.class);
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);

        } else {
            ToastUtils.showShort("请重新登陆");
            Intent mainIntent = new Intent(context, LoginActivity.class);
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);
        }
        Intent mainIntent = new Intent(context, MainActivity.class);
        mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(mainIntent);
    }
}
